#include "cameraanimationlayer.h"
#include "stringproperty.h"

namespace VrDataCore
{
	CameraAnimationLayer::CameraAnimationLayer()
	{
		setClassName(CLASS_CAMERA_ANIMATION_LAYER);
	}

	CameraAnimationLayer::~CameraAnimationLayer()
	{}

	void CameraAnimationLayer::onMapLoadEnd(CoreBase::Map* map)
	{
		QMap<QString,osg::ref_ptr<CoreBase::ActorBase>> allactors = map->getAllActors();
		QMap<QString,osg::ref_ptr<CoreBase::ActorBase>>::Iterator iter = allactors.begin();
		for(;iter!=allactors.end();++iter)
		{
			if(iter.value()->isInstanceOf(CLASS_CAMERA_ANIMATION) || iter.value()->isInstanceOf(CLASS_IMP_CAMERA_ANIMATION)
				|| iter.value()->isInstanceOf(CLASS_CAMERA_START_INFO))
			{
				addChild(iter.value().get());
			}
		}
	}

	void CameraAnimationLayer::removeChild(CoreBase::ActorBase* mactor)
	{
		if(mactor==NULL)
			return;
		_allChild.remove(mactor->getId());
		if(getBelongMap())
			getBelongMap()->removeActor(*mactor);
	}

	void CameraAnimationLayer::createDrawable()
	{
		SingleLayerActor::createDrawable();
		setTraverseMask(NODE_MASK_NOSELECT);
		setInitialTraverseMask(NODE_MASK_NOSELECT);
	}
}